/*****************************************************
** Author:
** Date: 2019-10-19
*
*****************************************************/

#ifndef __COMM_H_
#define __COMM_H_

#ifdef __cplusplus
extern "C"{
#endif

#include <stdio.h>
#include <string.h>


#define DEBUG_LOG_ENABLE

#ifdef DEBUG_LOG_ENABLE
#define log_dbg(_fmt_, ...)     \
    printf("[DBG][%s:%d] "_fmt_"\n", __func__, __LINE__, ##__VA_ARGS__)
#else
#define log_dbg(_fmt_, ...)
#endif

#define log_inf(_fmt_, ...)     \
    printf("[INF][%s:%d] "_fmt_"\n", __func__, __LINE__, ##__VA_ARGS__)
#define log_wrn(_fmt_, ...)     \
    printf("[WRN][%s:%d] "_fmt_"\n", __func__, __LINE__, ##__VA_ARGS__)
#define log_err(_fmt_, ...)     \
    printf("[ERR][%s:%d] "_fmt_"\n", __func__, __LINE__, ##__VA_ARGS__)


#define DeepOfArray(a)      (sizeof(a) / sizeof(*(a)))
#define CountOfString(a)    (sizeof(a) - 1)

#define Swap(a, b)          do { a ^= b; b ^= a; a ^= b; } while (0)
#define Floor(a, b)			(a - a % b)


struct tc
{
    char *name;
    void (*func)(void);
};


void dump_memory(const unsigned char *buff, unsigned int len, char *str, ...);
int str2hex(char *str, unsigned char *strhex, int maxsize);


#ifdef __cplusplus
}
#endif

#endif /* __COMM_H_ */

